use "C:\Users\Desktop\bullet_ballot_RR.dta"

**descriptive analysis of variables
tab centrust
tab loctrust
tab protest
tab shangfang
tab aware
tab vote
sum vote village gender age minority edu linc union partym gov_em avg

**ordered logit model for awareness of election and trust in government
ologit centrust aware gender age minority edu lin village union partym gov_em, robust nolog
ologit loctrust aware gender age minority edu linc village union partym gov_em, robust nolog


**Figures for ordered logit model for awareness of election and trust in government

ologit centrust aware gender age minority edu lin village union partym gov_em, robust nolog
quietly eststo cent1: margins, at(aware==(0,1)) predict(outcome(1)) atmeans vsquish post
coefplot, at title(Completely Untrustworthy, tstyle(size(medium))) ytitle() xtitle()  xlabel(0 "NO" 1"Yes") xscale(range(-0.2 1.2)) scheme(s1mono) name(g1)
ologit centrust aware gender age minority edu lin village union partym gov_em, robust nolog
quietly eststo cent2: margins, at(aware==(0,1)) predict(outcome(2)) atmeans vsquish post
coefplot, at title(Relatively Untrustworthy, tstyle(size(medium))) ytitle() xtitle()  xlabel(0 "NO" 1"Yes") xscale(range(-0.2 1.2)) scheme(s1mono) name(g2)
ologit centrust aware gender age minority edu lin village union partym gov_em, robust nolog
quietly eststo cent3: margins, at(aware==(0,1)) predict(outcome(3)) atmeans vsquish post
coefplot, at title(Between Untrustworthy and Trustworthy, tstyle(size(medium))) ytitle() xtitle()  xlabel(0 "NO" 1"Yes") xscale(range(-0.2 1.2)) scheme(s1mono) name(g3)
ologit centrust aware gender age minority edu lin village union partym gov_em, robust nolog
quietly eststo cent4: margins, at(aware==(0,1)) predict(outcome(4)) atmeans vsquish post
coefplot, at title(Relatively Trustworthy, tstyle(size(medium))) ytitle() xtitle()  xlabel(0 "NO" 1"Yes") xscale(range(-0.2 1.2)) scheme(s1mono) name(g4)
ologit centrust aware gender age minority edu lin village union partym gov_em, robust nolog
quietly eststo cent5: margins, at(aware==(0,1)) predict(outcome(5)) atmeans vsquish post
coefplot, at title(Completely Untrustworthy, tstyle(size(medium))) ytitle() xtitle()  xlabel(0 "NO" 1"Yes") xscale(range(-0.2 1.2)) scheme(s1mono) name(g5)
graph combine g1 g2 g3 g4 g5,  l1title(Predict Probability) b1title("Awareness of Residents'/Villagers' Elections") scheme(s1mono)

ologit loctrust aware gender age minority edu lin village union partym gov_em, robust nolog
quietly eststo loc1: margins, at(aware==(0,1)) predict(outcome(1)) atmeans vsquish post
coefplot, at title(Completely Untrustworthy, tstyle(size(medium))) ytitle() xtitle()  xlabel(0 "NO" 1"Yes") xscale(range(-0.2 1.2)) scheme(s1mono) name(f1)
ologit loctrust aware gender age minority edu lin village union partym gov_em, robust nolog
quietly eststo loc2: margins, at(aware==(0,1)) predict(outcome(2)) atmeans vsquish post
coefplot, at title(Relatively Untrustworthy, tstyle(size(medium))) ytitle() xtitle()  xlabel(0 "NO" 1"Yes") xscale(range(-0.2 1.2)) scheme(s1mono) name(f2)
ologit loctrust aware gender age minority edu lin village union partym gov_em, robust nolog
quietly eststo loc3: margins, at(aware==(0,1)) predict(outcome(3)) atmeans vsquish post
coefplot, at title(Between Untrustworthy and Trustworthy, tstyle(size(medium))) ytitle() xtitle()  xlabel(0 "NO" 1"Yes") xscale(range(-0.2 1.2)) scheme(s1mono) name(f3)
ologit loctrust aware gender age minority edu lin village union partym gov_em, robust nolog
quietly eststo loc4: margins, at(aware==(0,1)) predict(outcome(4)) atmeans vsquish post
coefplot, at title(Relatively Trustworthy, tstyle(size(medium))) ytitle() xtitle()  xlabel(0 "NO" 1"Yes") xscale(range(-0.2 1.2)) scheme(s1mono) name(f4)
ologit loctrust aware gender age minority edu lin village union partym gov_em, robust nolog
quietly eststo loc5: margins, at(aware==(0,1)) predict(outcome(5)) atmeans vsquish post
coefplot, at title(Completely Untrustworthy, tstyle(size(medium))) ytitle() xtitle()  xlabel(0 "NO" 1"Yes") xscale(range(-0.2 1.2)) scheme(s1mono) name(f5)
graph combine f1 f2 f3 f4 f5,  l1title(Predict Probability) b1title("Awareness of Residents'/Villagers' Elections") scheme(s1mono)

**logit model for awareness of elections and collective contentious activities
logit protest aware gender age minority edu linc village union partym gov_em, robust nolog
eststo m1
logit protest aware centrust loctrust gender age minority edu linc village union partym gov_em, robust nolog
eststo m2
logit protest vote gender age minority edu linc village union partym gov_em, robust nolog
eststo m3
logit protest vote centrust loctrust gender age minority edu linc village union partym gov_em, robust nolog
eststo m4
**logit model for awareness of elections and participation in collective shangfang
logit shangfang aware gender age minority edu linc village union partym gov_em, robust nolog
eststo m5
logit shangfang aware centrust loctrust gender age minority edu linc village union partym gov_em, robust nolog
eststo m6
logit shangfang vote gender age minority edu linc village union partym gov_em, robust nolog
eststo m7
logit shangfang vote centrust loctrust gender age minority edu linc village union partym gov_em, robust nolog
eststo m8
esttab m1 m2 m3 m4 m5 m6 m7 m8 using logitm.rtf, se


**instrumental variable models
ivregress 2sls centrust village gender age minority edu linc union partym gov_em (aware=avg), robust
ivregress 2sls loctrust village gender age minority edu linc union partym gov_em (aware=avg), robust
ivprobit protest village gender age minority edu linc union partym gov_em (aware=avg), nolog
ivprobit shangfang village gender age minority edu linc union partym gov_em (aware=avg), nolog



